package com.example.cofeed.adapter;

import android.widget.TextView;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Supply;
import com.example.cofeed.util.TempTimeUtils;


public class DemandAdapter extends BaseQuickAdapter<Supply, BaseViewHolder> {
    public DemandAdapter() {
        super(R.layout.adapter_demand);
    }

    @Override
    protected void convert(BaseViewHolder helper, Supply item) {
       TextView title = helper.itemView.findViewById(R.id.tv_name);
        switch (item.stype){
            case 1:
//                helper.setText(R.id.tv_name, "供应: " + item.title);

                title.setCompoundDrawablesWithIntrinsicBounds(mContext.getResources().getDrawable(R.mipmap.gong), null, null, null);
                break;
            case 2:
//                helper.setText(R.id.tv_name, "求购: " + item.title);

                title.setCompoundDrawablesWithIntrinsicBounds(mContext.getResources().getDrawable(R.mipmap.qiu), null, null, null);
                break;
            case 3:
//                helper.setText(R.id.tv_name, "招商: " + item.title);

                title.setCompoundDrawablesWithIntrinsicBounds(mContext.getResources().getDrawable(R.mipmap.zhao), null, null, null);
                break;
        }

        helper.setText(R.id.tv_name, item.title);

        helper.setText(R.id.tv_tidaidi, "" + item.pick_place);
        helper.setText(R.id.tv_shuliang, "数量: " + item.number);
//        item.addtime = "2018-11-29 10:47:35";
        helper.setText(R.id.tv_date, "时间：" + TempTimeUtils.getFriendlyTimeSpanByNow(item.addtime));
        helper.setText(R.id.tv_jiage, "价格: " + item.price);
        helper.setText(R.id.tv_changjia, "产地/厂家: " + item.product);
        helper.setText(R.id.tv_guige, "规格/质量: " + item.material);

    }
}
